<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HRMS - 人力资源管理系统</title>
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="<c:url value='/webjars/bootstrap/5.3.2/css/bootstrap.min.css'/>">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="<c:url value='/webjars/font-awesome/6.5.1/css/all.min.css'/>">
    <style>
        .feature-card {
            transition: transform 0.2s;
        }
        .feature-card:hover {
            transform: translateY(-5px);
        }
        .feature-icon {
            font-size: 2rem;
            margin-bottom: 1rem;
        }
    </style>
</head>
<body>
<!-- 导航栏 -->
<!-- 导航栏 -->
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
    <div class="container">
        <a class="navbar-brand" href="<c:url value='/'/>">HRMS</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
            <span class="navbar-toggler-icon"></span>
        </button>
        <ul class="navbar-nav">
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
                   data-bs-toggle="dropdown">
                    <i class="fas fa-user"></i> ${loginUser.empName}
                </a>
                <ul class="dropdown-menu dropdown-menu-end">
                    <li>
                        <a class="dropdown-item" href="${pageContext.request.contextPath}/auth/profile">
                            <i class="fas fa-id-card"></i> 个人信息
                        </a>
                    </li>
                    <li><hr class="dropdown-divider"></li>
                    <li>
                        <a class="dropdown-item" href="${pageContext.request.contextPath}/auth/logout">
                            <i class="fas fa-sign-out-alt"></i> 退出登录
                        </a>
                    </li>
                </ul>
            </li>
        </ul>
    </div>
</nav>

<!-- 消息提示 -->
<c:if test="${not empty message}">
    <div class="toast-container position-fixed bottom-0 end-0 p-3">
        <div id="liveToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
            <div class="toast-header ${success ? 'bg-success' : 'bg-danger'} text-white">
                <strong class="me-auto">系统提示</strong>
                <button type="button" class="btn-close btn-close-white" data-bs-dismiss="toast" aria-label="关闭"></button>
            </div>
            <div class="toast-body">
                    ${message}
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            var toastEl = document.getElementById('liveToast');
            if (toastEl) {
                var toast = new bootstrap.Toast(toastEl);
                toast.show(); // 显示Toast
            }
        });
    </script>
</c:if>

<!-- 主要内容 -->
<div class="container py-5">
    <h2 class="text-center mb-4">功能导航</h2>
    <div class="row g-4">
        <!-- 人事管理功能 -->
        <c:if test="${sessionScope.empRole == 5 || sessionScope.empRole == 2 || sessionScope.empRole == 1}">
            <div class="col-md-6 col-lg-4">
                <div class="card h-100 feature-card">
                    <div class="card-body text-center">
                        <div class="feature-icon text-primary">
                            <i class="fas fa-users"></i>
                        </div>
                        <h5 class="card-title">人事管理</h5>
                        <p class="card-text">管理员工信息、处理入职离职、员工调动等</p>
                        <a href="<c:url value='/hr/employee/list'/>" class="btn btn-primary">进入</a>
                    </div>
                </div>
            </div>
            <c:if test="${sessionScope.empRole == 5 || sessionScope.empRole == 2}">
                <div class="col-md-6 col-lg-4">
                    <div class="card h-100 feature-card">
                        <div class="card-body text-center">
                            <div class="feature-icon text-success">
                                <i class="fas fa-check-circle"></i>
                            </div>
                            <h5 class="card-title">变更审核</h5>
                            <p class="card-text">审核员工信息变更申请</p>
                            <a href="<c:url value='/hr/change/list'/>" class="btn btn-success">进入</a>
                        </div>
                    </div>
                </div>
            </c:if>
        </c:if>

        <!-- 薪资管理功能 -->
        <c:if test="${sessionScope.empRole == 5 || sessionScope.empRole == 4 || sessionScope.empRole == 3}">
            <div class="col-md-6 col-lg-4">
                <div class="card h-100 feature-card">
                    <div class="card-body text-center">
                        <div class="feature-icon text-warning">
                            <i class="fas fa-money-bill-wave"></i>
                        </div>
                        <h5 class="card-title">薪资标准</h5>
                        <p class="card-text">管理薪资标准和等级</p>
                        <a href="<c:url value='/salary/standard/list'/>" class="btn btn-warning">进入</a>
                    </div>
                </div>
            </div>
            <div class="col-md-6 col-lg-4">
                <div class="card h-100 feature-card">
                    <div class="card-body text-center">
                        <div class="feature-icon text-info">
                            <i class="fas fa-file-invoice-dollar"></i>
                        </div>
                        <h5 class="card-title">薪资发放</h5>
                        <p class="card-text">管理月度薪资发放</p>
                        <a href="<c:url value='/salary/payment/list'/>" class="btn btn-info">进入</a>
                    </div>
                </div>
            </div>
            <c:if test="${sessionScope.empRole == 5 || sessionScope.empRole == 4}">
                <div class="col-md-6 col-lg-4">
                    <div class="card h-100 feature-card">
                        <div class="card-body text-center">
                            <div class="feature-icon text-danger">
                                <i class="fas fa-tasks"></i>
                            </div>
                            <h5 class="card-title">薪资审核</h5>
                            <p class="card-text">审核薪资变更和发放</p>
                            <a href="<c:url value='/salary/change/list'/>" class="btn btn-danger">进入</a>
                        </div>
                    </div>
                </div>
            </c:if>
        </c:if>

        <!-- 所有用户都有的功能 -->
        <div class="col-md-6 col-lg-4">
            <div class="card h-100 feature-card">
                <div class="card-body text-center">
                    <div class="feature-icon text-primary">
                        <i class="fas fa-user"></i>
                    </div>
                    <h5 class="card-title">个人信息</h5>
                    <p class="card-text">查看和管理个人信息</p>
                    <a href="<c:url value='/auth/profile'/>" class="btn btn-primary">进入</a>
                </div>
            </div>
        </div>
        <div class="col-md-6 col-lg-4">
            <div class="card h-100 feature-card">
                <div class="card-body text-center">
                    <div class="feature-icon text-success">
                        <i class="fas fa-money-check-alt"></i>
                    </div>
                    <h5 class="card-title">薪资查询</h5>
                    <p class="card-text">查看个人薪资信息</p>
                    <a href="<c:url value='/salary/payment/personal'/>" class="btn btn-success">进入</a>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 页脚 -->
<footer class="footer mt-auto py-3 bg-light">
    <div class="container text-center">
        <span class="text-muted"> 2024 HRMS. All rights reserved.</span>
    </div>
</footer>

<!-- JavaScript 依赖 -->
<script src="<c:url value='/webjars/jquery/3.7.1/jquery.min.js'/>"></script>
<script src="<c:url value='/webjars/bootstrap/5.3.2/js/bootstrap.bundle.min.js'/>"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<script>
    function logout() {
        if (confirm('确定要退出登录吗？')) {
            $.post('<c:url value="/auth/logout"/>', function(response) {
                if (response.success) {
                    window.location.href = '<c:url value="/auth/login"/>';
                } else {
                    alert(response.message);
                }
            });
        }
    }
</script>
</body>
</html>

